package lagou.homework.lagouhomework.Unit3.code.q4;

import java.util.List;

public class DeleteStu {
    public static void delStu(int id, List<Student> listStu) {
        // 遍历学生对象List
        for (Student stu : listStu) {
            int key = listStu.indexOf(stu);     // 获取当前对象索引
            if (id == stu.getId()) {            // 如果能查到到，则进行删除
                listStu.remove(key);          // 删除
                System.out.println("删除成功！");

            }else{
                System.out.println("未查找到学号为"+stu.getId()+"的学生！");
            }
        }

    }
}
